package com.puntodonna.fogliocassa.client.action;

import com.gwtplatform.dispatch.shared.UnsecuredActionImpl;
import com.puntodonna.fogliocassa.shared.FoglioCassaObj;
import com.puntodonna.fogliocassa.shared.MovimentoObj;
import com.puntodonna.fogliocassa.shared.UserObj;

public class PersistanceAction extends UnsecuredActionImpl<PersistanceActionResult> {
	
	public static final String ACTION_FC_GETALL = "fc_getAll";
	public static final String ACTION_FC_SAVE = "fc_save";
	public static final String ACTION_FC_UPDATE = "fc_update";
	public static final String ACTION_FC_DELETE = "fc_delete";
	
	public static final String ACTION_MV_SAVE = "mv_save";
	public static final String ACTION_MV_UPDATE = "mv_update";
	public static final String ACTION_MV_DELETE = "mv_delete";

	private String action;
	
	private FoglioCassaObj foglioCassaObj;
	private MovimentoObj movimentoObj;
	private UserObj userObj;

	private PersistanceAction() {
		// For serialization only
	}

	public String getAction() {
		return action;
	}
	
	public FoglioCassaObj getFoglioCassaObj() {
		return foglioCassaObj;
	}
	
	public MovimentoObj getMovimentoObj() {
		return movimentoObj;
	}
	
	public UserObj getUserObj() {
		return userObj;
	}
	
	public static PersistanceAction getAllFoglioCassaPersistanceAction(UserObj userObj){
		PersistanceAction persistanceAction = new PersistanceAction();
		persistanceAction.action = ACTION_FC_GETALL;
		persistanceAction.userObj = userObj;
		return persistanceAction;
	}
	
	public static PersistanceAction getFoglioCassaPersistanceAction(String action, UserObj userObj, FoglioCassaObj foglioCassaObj){
		PersistanceAction persistanceAction = new PersistanceAction();
		persistanceAction.action = action;
		persistanceAction.foglioCassaObj = foglioCassaObj;
		persistanceAction.userObj = userObj;
		return persistanceAction;
	}
	
	public static PersistanceAction getMovimentoPersistanceAction(String action, MovimentoObj movimentoObj, FoglioCassaObj foglioCassaObj){
		PersistanceAction persistanceAction = new PersistanceAction();
		persistanceAction.action = action;
		persistanceAction.movimentoObj = movimentoObj;
		persistanceAction.foglioCassaObj = foglioCassaObj;
		return persistanceAction;
	}
}
